Skip to main content

All Questions

3votes
4answers
780views

Is it a bad practice to have an interface method to tell whether it can handle an object?

interface Resolver { boolean canResolve(SomeInput input); SomeOutput resolve(SomeInput input); } public static void main(String[] args) { List<Resolver> resolvers = ...; ...
Martin Tarjányi's user avatar
3votes
2answers
207views

Checking the user in almost all use cases

I have a web application that has Users that belong to Companies. A User can only belong to 1 Company at a time and they can manage their own company information. I'm using java spring and I'm ...
Jordi Pagès's user avatar
4votes
3answers
1kviews

Passing object or using the field

I would like to know what is a more appropriate way to code in Java. Is it generally better to pass entire objects in the method's parameters or just using the fields from the class? Using the field: ...
max's user avatar
  • 163
1vote
1answer
746views

Where and how to connect to external API in my service class?

In my service class I would like to connect to external API. Where and how should I do it? 1) Inject in constructor ExternalClass and assign to private property. Next in other property in constructor ...
maxu's user avatar
5votes
2answers
8kviews

Design pattern for processing a huge CSV file -- Java

I am learning design patterns in Java and also working on a problem where I need to handle huge number of requests streaming into my program from a huge CSV file on the disk. Each CSV line is one ...
Shad's user avatar
3votes
1answer
540views

Contract interface/class with inner classes/interfaces

Brief description of my project structure. I have some base classes like BaseView, BasePresenter ... . Also my project consists of modules, module represents one complete part of the application. ...
CROSP's user avatar
  • 1,558
2votes
3answers
205views

Data duplication, can it be an unavoidable practice in this example?

Say I have different employees of type Employee stored in a list inside a class SubCase. public class SubCase{ protected ArrayList<Employee> employees; ... } SubCase represents a part ...
CedricCornelis's user avatar
1vote
1answer
182views

Better way to organize query methods in Android?

In my Android app I have: A SQLiteHelper class that extends SQLIteOpenHelper, and takes care of things like table-creation and upgrades. A SQLiteDatasource class that performs CRUD operations on the ...
AJJ's user avatar
  • 3,028
3votes
2answers
3kviews

Using MVC style, where is the best place to put SQL functionality?

I am wondering about best practices here. MVC (Model - View - Controller) patterns involve separating components of your program that model the data, manipulate those models, and display those ...
AJJ's user avatar
  • 3,028
2votes
1answer
274views

Is it OK to deprecate methods that need to be public due to the packaging model but are not to be used outside the codebase in Java?

I am currently working on a semi-large project that has several packages. There are 3 main packages, a "client" package, a "server" package and a "common" package. There are two jars, one for the ...
john01dav's user avatar
3votes
3answers
2kviews

Parallel Class/Interface Hierarchy with the Facade Design Pattern?

About a third of my code is wrapped inside a Facade class. Note that this isn't a "God" class, but actually represents a single thing (called a Line). Naturally, it delegates responsibilities to the ...
sinθ's user avatar
  • 1,311
4votes
2answers
1kviews

Can classes violate Single Responsibility if they delegate internal tasks?

I have two classes Output and Timeline, neither of which violate SR, but the two of them are linked together. So what I'd like to do is have a class called Elco (there's a reason behind the name) that ...
sinθ's user avatar
  • 1,311
4votes
2answers
194views

Should I write a wrapper within a manager object?

I have three classes that work together to do one function (from the perspective of the rest of my program). There is a little bit of set up between them, so, to make it easier for the rest of my ...
sinθ's user avatar
  • 1,311
4votes
2answers
5kviews

How to delete an object when other things reference it (and not making the code full of inter-dependencies)

The situation: In my program, there are a list of cues. To call a cue at a certain time, there are objects called Triggers. Cues have many public methods that allow them, among other things, to be "...
sinθ's user avatar
  • 1,311
0votes
1answer
83views

How to record/store edits?

In many programs and web apps (stack exchange included) the program is able to backtrack what edits where made to the piece. My issue is similar: I want to be able to store a "timeline" of edits, ...
sinθ's user avatar
  • 1,311

153050per page
close